home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 014 / dex / dex.l < prev    next >
Text File  |  1995-03-17  |  3KB  |  149 lines

  1. %{
  2. /************************************************************************
  3.  *                                    *
  4.  *            Copyright (c) 1982, Fred Fish            *
  5.  *                All Rights Reserved                *
  6.  *                                    *
  7.  *    This software and/or documentation is released for public    *
  8.  *    distribution for personal, non-commercial use only.        *
  9.  *    Limited rights to use, modify, and redistribute are hereby    *
  10.  *    granted for non-commercial purposes, provided that all        *
  11.  *    copyright notices remain intact and all changes are clearly    *
  12.  *    documented.  The author makes no warranty of any kind with    *
  13.  *    respect to this product and explicitly disclaims any implied    *
  14.  *    warranties of merchantability or fitness for any particular    *
  15.  *    purpose.                            *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FILE
  23.  *
  24.  *    dex.l   lex specification for documentation extraction utility
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    lex specification
  29.  *    dex
  30.  *
  31.  *  SYNOPSIS
  32.  *
  33.  *    lex dex.l
  34.  *    mv lex.yy.c dex.lo
  35.  *
  36.  *  DESCRIPTION
  37.  *
  38.  *    This file contains the lex specification for the "dex"
  39.  *    documentation extraction utility.  It is used with the file
  40.  *    "dex.y", which is the yacc specification, to generate the
  41.  *    source file parser.
  42.  *
  43.  *  AUTHOR
  44.  *
  45.  *    Fred Fish
  46.  *
  47.  */
  48. %}
  49.  
  50. cch    [*#;|]
  51. ncch    [^*#;|]
  52. blank    " "
  53. tab    \t
  54. white    ({tab}|{blank})
  55.  
  56. %START DLINE
  57.  
  58. %%
  59. %{
  60. extern int debug;
  61. %}
  62.  
  63. ^{white}*{cch}{blank}{blank}+    {
  64.             BEGIN DLINE;
  65.             if (debug) {printf("yylex: HSTART \"%s\"\n",yytext);}
  66.             return(HSTART);
  67.         }
  68.  
  69. ^{white}*{cch}{tab}    {
  70.             BEGIN DLINE;
  71.             if (debug) {printf("yylex: FSTART \"%s\"\n",yytext);}
  72.             return(FSTART);
  73.         }
  74.  
  75. ^{white}*{cch}{tab}{tab}    {
  76.             BEGIN DLINE;
  77.             if (debug) {printf("yylex: UFSTART \"%s\"\n",yytext);}
  78.             return(UFSTART);
  79.         }
  80.  
  81. ^{white}*{cch}[\t ]*$    {
  82.             BEGIN 0;
  83.             if (debug) {printf("yylex: BSTART \"%s\"\n",yytext);}
  84.             return(BSTART);
  85.         }
  86.  
  87. <DLINE>[^\n]*    {
  88.             if (debug) {printf("yylex: TEXT \"%s\"\n",yytext);}
  89.             return(TEXT);
  90.         }
  91.  
  92. \n        {
  93.             BEGIN 0;
  94.             if (debug) {printf("yylex: NEWLINE \"%s\"\n",yytext);}
  95.             return(NEWLINE);
  96.         }
  97. ^{white}+$    {
  98.             BEGIN 0;
  99.             if (debug) {printf("yylex: JUNK1 \"%s\"\n",yytext);}
  100.             return(JUNK);
  101.         }
  102. ^{white}*[^*#;| \t\n][^\n]* {
  103.             BEGIN 0;
  104.             if (debug) {printf("yylex: JUNK2 \"%s\"\n",yytext);}
  105.             return(JUNK);
  106.         }
  107. ^{white}*{cch}[^ \t\n][^\n]* {
  108.             BEGIN 0;
  109.             if (debug) {printf("yylex: JUNK3 \"%s\"\n",yytext);}
  110.             return(JUNK);
  111.         }
  112.  
  113. [\001-\177]    {
  114.             BEGIN 0;
  115.             if (debug) {printf("yylex: JUNK4 \"%s\"\n",yytext);}
  116.             return(JUNK);
  117.         }
  118.  
  119. %%
  120. extern FILE *infp;
  121.  
  122. #undef input            /* Make preprocessor forget macro */
  123. input()
  124. {
  125.     char ch;
  126.  
  127.     ch = fgetc(infp);
  128.     switch(ch) {
  129.     case EOF:
  130.     ch = NULL;
  131.     break;
  132.     case NULL:
  133.     ch = '\n';
  134.         break;
  135.     }
  136.     ch &= '\177';
  137.     return(ch);
  138. }
  139.  
  140. #undef unput            /* Make preprocessor forget macro */
  141. unput(ch)
  142. char ch;
  143. {
  144.     if (ch == NULL) {
  145.     ch = EOF;
  146.     }
  147.     ungetc(ch,infp);
  148. }
  149.